<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<style>
			body {
				margin: 4px;
				font-family: Helvetica;
			}
			/* .masonry {
				column-count: 4;
				column-gap: 0;
			}
			.item {
				position: relative;
				padding: 2px;
				counter-increment: item-counter;
			}
			.item img {
				display: block;
				width: 100%;
				height: auto;
			}
			.item::after {
				position: absolute;
				display: block;
				top: 2px;
				left: 2px;
				width: 24px;
				height: 24px;
				text-align: center;
				line-height: 24px;
				background: #000;
				color: #fff;
				content: counter(item-counter);
			} */
			/* flex box */
			.masonry {
				display: flex;
				flex-direction: column;
				flex-wrap: wrap;
				height: 3000px;
			}
			.item {
				position: relative;
				width: 25%;
				padding: 2px;
				box-sizing: border-box;
				counter-increment: item-counter;
			}
			.item img {
				display: block;
				width: 100%;
				height: auto;
			}
			.item::after {
				position: absolute;
				display: block;
				top: 2px;
				left: 2px;
				width: 24px;
				height: 24px;
				text-align: center;
				line-height: 24px;
				background: #000;
				color: #fff;
				content: counter(item-counter);
			}
			.item:nth-child(4n + 1) {
				order: 1;
			}
			.item:nth-child(4n + 2) {
				order: 2;
			}
			.item:nth-child(4n + 3) {
				order: 3;
			}
			.item:nth-child(4n) {
				order: 4;
			}
		</style>
	</head>
	<body>
		<div class="masonry">
			<div class="item"><img src="https://picsum.photos/360/410?random=1" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/420?random=2" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/430?random=3" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/440?random=4" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/450?random=5" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/460?random=6" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/470?random=7" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/480?random=8" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/490?random=9" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/410?random=10" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/411?random=11" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/412?random=12" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/413?random=13" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/414?random=14" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/415?random=15" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/416?random=16" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/417?random=17" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/418?random=18" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/419?random=19" alt="" /></div>
			<div class="item"><img src="https://picsum.photos/360/420?random=20" alt="" /></div>
		</div>
	</body>
</html>
